package com.hujesse.service;

import com.google.gson.Gson;
import com.hujesse.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class DeptServiceFallBackFactory implements FallbackFactory {
    @Override
    public DeptService create(Throwable cause) {
        return new DeptService() {
            @Override
            public String addDept(Dept dept) {
                return null;
            }
            @Override
            public String  getId(Long id) {
                return new Gson().toJson( new Dept()
                        .setDeptId(id)
                        .setDeptName("id=>" + id + "没有对应的信息，客户端提供了降级的信息，这个服务现在已经被关闭@hystrix降级")
                        .setDbName("没有数据~"));
            }
            @Override
            public String getList() {
                return null;
            }
        };
    }

}
